//
// Created by root on 2/22/18.
//

#ifndef FUNNY_TRANSLATOR_OOP_H
#define FUNNY_TRANSLATOR_OOP_H

#include <stdio.h>
#include "../premise/premise.h"

#define END_OF_OOP_LOOP  "end"
#define OOP_LOOP_PROP    "property"
#define OOP_LOOP_METHOD  "method"
//#define END_OF_OOP_MACRO_LOOP    OOP_MACRO_LOOP # END_OF_OOP_MACRO
//#define END_OF_OOP_MACRO_PROP    OOP_MACRO_PROP # END_OF_OOP_MACRO
//#define END_OF_OOP_MACRO_METHOD  OOP_MACRO_METHOD # END_OF_OOP_MACRO

#define TYPE_PLAIN_TEXT   1
#define TYPE_PLAIN_PARAM  2
#define TYPE_LOOP_TEXT    3
#define TYPE_LOOP_PROP    4
#define TYPE_LOOP_METHOD  5

#define TYPE_TEXT   1
#define TYPE_PARAM  2

typedef struct _OopCodeBlock {
    String code;
    int type;
} OopCodeBlock;

typedef struct _OopCodeNode {
    const char *loopBlockName;
    union {
        OopCodeBlock *plainBlock;
        Queue *loopBlock;
    };
} OopCodeNode;

typedef char* (*OopMacro)(char* code, Map params);

void* parse_oop_gen(FILE* file);
String gen_oop_code(String category, Map params, Queue *properties, Queue *methods);
String gen_defclass_code(TreeNode *classNode);
String gen_getprop_code(String object, String property);
String gen_setprop_code(String object, String property, String value);
String gen_sendmsg_code(String object, String message, String args);
String gen_newinstance_code(TreeNode* classNode, Map assignments);

#endif //FUNNY_TRANSLATOR_OOP_H
